package com.example.administrator.shandon2020_1.util;

import android.content.Context;
import android.content.SharedPreferences;

import java.util.HashMap;
import java.util.Map;

public class SaveandGet {
    public static void saveacc(String acc, Context context){
        SharedPreferences sp=context.getSharedPreferences("data.xml",Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("acc",acc);
        edit.commit();
    }
    public static String getacc(Context context){
        SharedPreferences sp=context.getSharedPreferences("data.xml",Context.MODE_PRIVATE);
        String acc = sp.getString("acc", null);
        return acc;
    }
    public static void save(String ip,String username,String password,String id,String temp_id,String fan_id,String rate,String fan_Do,Context context){
        SharedPreferences sp=context.getSharedPreferences("data.xml",Context.MODE_PRIVATE);
        SharedPreferences.Editor edit = sp.edit();
        edit.putString("ip",ip);
        edit.putString("username",username);
        edit.putString("password",password);
        edit.putString("id",id);
        edit.putString("temp_id",temp_id);
        edit.putString("fan_id",fan_id);
        edit.putString("rate",rate);
        edit.putString("fan_Do",fan_Do);
    }

    public static Map<String,String> get(Context context){
        SharedPreferences sp=context.getSharedPreferences("data.xml",Context.MODE_PRIVATE);
        Map<String,String> map=new HashMap<>();
        map.put("ip",sp.getString("ip",null));
        map.put("username",sp.getString("username",null));
        map.put("password",sp.getString("password",null));
        map.put("id",sp.getString("id",null));
        map.put("temp_id",sp.getString("temp_id",null));
        map.put("fan_id",sp.getString("fan_id",null));
        map.put("rate",sp.getString("rate",null));
        map.put("fan_Do",sp.getString("fan_Do",null));
        return map;
    }

}
